package interfacesSIAB;

import java.awt.BorderLayout;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
import java.awt.Color;
import javax.swing.border.TitledBorder;
import java.awt.Font;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


import javax.swing.JTextField;
import javax.swing.JButton;

import administrador.gestion_de_clientes;
import administrador.gestion_de_empleados;

public class IngresarEmpleado extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JPanel jPanel = null;
	private JLabel Nombre = null;
	private JTextField nombre = null;
	private JLabel Nombre1 = null;
	private JLabel Cedula = null;
	private JTextField apellido = null;
	private JTextField cedula = null;
	private JLabel Cedula1 = null;
	private JLabel jLabel = null;
	private JTextField telefono = null;
	private JTextField direccion = null;
	private JLabel jLabel1 = null;
	private JTextField email = null;
	private JButton guardar = null;
	private JLabel fechaIngreso = null;
	private JTextField fechaIngreso1 = null;
	private JLabel fechaRetiro = null;
	private JTextField fechaRetiro1 = null;
	private JLabel cargo = null;
	private JTextField cargo1 = null;
	private JButton cancelar = null;
	/**
	 * This is the default constructor
	 */
	public IngresarEmpleado() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(366, 501);
		this.setResizable(false);
		this.setForeground(Color.blue);
		this.setFont(new Font("Arial", Font.BOLD, 14));
		this.setContentPane(getJContentPane());
		this.setTitle("Empleado");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJPanel(), null);
			jContentPane.add(getGuardar(), null);
			jContentPane.add(getCancelar(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			cargo = new JLabel();
			cargo.setBounds(new Rectangle(19, 336, 49, 16));
			cargo.setText("Cargo");
			fechaRetiro = new JLabel();
			fechaRetiro.setBounds(new Rectangle(17, 307, 90, 16));
			fechaRetiro.setText("Fecha de Retiro");
			fechaIngreso = new JLabel();
			fechaIngreso.setBounds(new Rectangle(18, 272, 100, 16));
			fechaIngreso.setText("Fecha de Ingreso");
			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(20, 198, 68, 22));
			jLabel1.setText("Direccion");
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(21, 236, 66, 16));
			jLabel.setText("Email");
			Cedula1 = new JLabel();
			Cedula1.setBounds(new Rectangle(17, 160, 68, 16));
			Cedula1.setText(" Telefono");
			Cedula = new JLabel();
			Cedula.setBounds(new Rectangle(17, 123, 67, 16));
			Cedula.setText(" Cedula");
			Nombre1 = new JLabel();
			Nombre1.setBounds(new Rectangle(19, 87, 66, 16));
			Nombre1.setText(" Apelido(s)");
			Nombre = new JLabel();
			Nombre.setBounds(new Rectangle(18, 51, 66, 21));
			Nombre.setText(" Nombre(s)");
			jPanel = new JPanel();
			jPanel.setLayout(null);
			jPanel.setBounds(new Rectangle(15, 36, 306, 387));
			jPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.orange), "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)), "Datos del Empleado", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
			jPanel.add(Nombre, null);
			jPanel.add(getNombre(), null);
			jPanel.add(Nombre1, null);
			jPanel.add(Cedula, null);
			jPanel.add(getApellido(), null);
			jPanel.add(getCedula(), null);
			jPanel.add(Cedula1, null);
			jPanel.add(jLabel, null);
			jPanel.add(getTelefono(), null);
			jPanel.add(getDireccion(), null);
			jPanel.add(jLabel1, null);
			jPanel.add(getEmail(), null);
			jPanel.add(fechaIngreso, null);
			jPanel.add(getFechaIngreso1(), null);
			jPanel.add(fechaRetiro, null);
			jPanel.add(getFechaRetiro1(), null);
			jPanel.add(cargo, null);
			jPanel.add(getCargo1(), null);
		}
		return jPanel;
	}

	/**
	 * This method initializes nombre	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getNombre() {
		if (nombre == null) {
			nombre = new JTextField();
			nombre.setBounds(new Rectangle(147, 50, 139, 20));
		}
		return nombre;
	}

	/**
	 * This method initializes apellido	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getApellido() {
		if (apellido == null) {
			apellido = new JTextField();
			apellido.setBounds(new Rectangle(147, 84, 138, 20));
		}
		return apellido;
	}

	/**
	 * This method initializes cedula	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getCedula() {
		if (cedula == null) {
			cedula = new JTextField();
			cedula.setBounds(new Rectangle(148, 119, 138, 20));
		}
		return cedula;
	}

	/**
	 * This method initializes telefono	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTelefono() {
		if (telefono == null) {
			telefono = new JTextField();
			telefono.setBounds(new Rectangle(147, 156, 138, 20));
		}
		return telefono;
	}

	/**
	 * This method initializes direccion	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getDireccion() {
		if (direccion == null) {
			direccion = new JTextField();
			direccion.setBounds(new Rectangle(147, 193, 139, 20));
		}
		return direccion;
	}

	/**
	 * This method initializes email	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getEmail() {
		if (email == null) {
			email = new JTextField();
			email.setBounds(new Rectangle(146, 228, 139, 20));
		}
		return email;
	}

	/**
	 * This method initializes guardar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getGuardar() {
		if (guardar == null) {
			guardar = new JButton();
			guardar.setText("Guardar");

			guardar.setBounds(new Rectangle(46, 439, 82, 22));
			guardar.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					
					try {
					
						
						if(getNombre().getText().trim().length() > 0 )
						{
							if(getApellido().getText().trim().length() > 0)
							{
								
								if(getCedula().getText().trim().length() > 0)
								
								{
																	
									gestion_de_empleados agregar= new gestion_de_empleados();
									
									
									if (agregar.agregarEmpleado(getNombre().getText(),getApellido().getText(),Integer.parseInt(getCedula().getText()),Integer.parseInt(getTelefono().getText()),getDireccion().getText(),getEmail().getText(),getFechaIngreso1().getText(),getFechaRetiro1().getText(),Integer.parseInt(getCargo1().getText()))==true){
									getNombre().setText(" ");
									getApellido().setText("");
									getCedula().setText("");
									getTelefono().setText("");
									getDireccion().setText("");
									getEmail().setText("");
									getFechaIngreso1().setText("");
									getFechaRetiro1().setText("");
									getCargo1().setText("");
									JOptionPane.showMessageDialog(null,"El Empleado fue Agregado al Sistema");
									}
									

									getNombre().setRequestFocusEnabled(true);
								}
								else{
									JOptionPane.showMessageDialog(null,"Por favor Debe de Ingresar la Cedula");
								}
								
								
							}
							else{
								JOptionPane.showMessageDialog(null,"Por favor Debe de Ingresar el Apellido");
							}
							
							
							
							
							
						}
						else{
							
							JOptionPane.showMessageDialog(null,"Por favor Debe de Ingresar el Nombre");
						}
						
						
						}
						catch (Exception e1) {
							
							
							JOptionPane.showMessageDialog(null, "El siguiente campo de datos  "+ e1.getMessage()+"  no corresponde al tipo del campo");
						    e1.printStackTrace();
						}
						
					  
					   
					   
					
					
				
				}
			});
			
			
			
			
			
			
			
		}
		return guardar;
	}

	/**
	 * This method initializes fechaIngreso1	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getFechaIngreso1() {
		if (fechaIngreso1 == null) {
			fechaIngreso1 = new JTextField();
			fechaIngreso1.setBounds(new Rectangle(148, 267, 135, 20));
			fechaIngreso1.setText("2012-05-28");
		}
		return fechaIngreso1;
	}

	/**
	 * This method initializes fechaRetiro1	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getFechaRetiro1() {
		if (fechaRetiro1 == null) {
			fechaRetiro1 = new JTextField();
			fechaRetiro1.setBounds(new Rectangle(147, 301, 136, 20));
		}
		return fechaRetiro1;
	}

	/**
	 * This method initializes cargo1	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getCargo1() {
		if (cargo1 == null) {
			cargo1 = new JTextField();
			cargo1.setBounds(new Rectangle(146, 337, 136, 20));
		}
		return cargo1;
	}

	/**
	 * This method initializes cancelar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCancelar() {
		if (cancelar == null) {
			cancelar = new JButton();
			cancelar.setBounds(new Rectangle(179, 438, 88, 25));
			cancelar.setText("Salir");
			
cancelar.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					
					dispose();
				}
			});
			
			
			
			
			
			
			
			
			
		}
		return cancelar;
	}

}  //  @jve:decl-index=0:visual-constraint="33,12"
